/**
 * Created by gs on 2017/1/19.
 */

exports.pageInit = function (totalCount, pageSize, pageNum) {
    if (!pageSize || pageSize <= 10) {
        pageSize = 10;
    }
    if (!totalCount || totalCount <= 0) {
        totalCount = 0;
    }
    var totalPage = 0;
    var s = totalCount / pageSize;
    if (s === 0) {
        totalPage = parseInt(s);
    } else {
        totalPage = parseInt(s) + 1;
    }
    if (!pageNum || pageNum <= 1) {
        pageNum = 1;
    }else if(pageNum >= totalPage){
        pageNum = totalPage;
    }
    return {totalCount: totalCount, pageSize: pageSize, pageNum: pageNum, totalPage: totalPage};
}